home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / filesyst / dosfs / dmsdosfs.000 / dmsdosfs / dmsdosfs-0.6.9b / dmsdos_fs.h < prev    next >
C/C++ Source or Header  |  1996-07-29  |  13KB  |  346 lines

  1. #ifndef _LINUX_DMSDOS_FS_H
  2. #define _LINUX_DMSDOS_FS_H
  3.  
  4. /*
  5.  * The DMSDOS filesystem constants/structures
  6.  */
  7.  
  8. #include <linux/autoconf.h>
  9.  
  10. #include <linux/fs.h>
  11. #include <linux/stat.h>
  12. #include <linux/fd.h>
  13.  
  14. #define DMSDOS_VERSION 0x00000609
  15. #define DMSDOS_LT      "b"
  16. #define DMSDOS_LOWEST_COMPATIBLE_VERSION 0x00000608
  17.  
  18. /* MAXFRAGMENT value:
  19.    Increase this value if you get a 'CVF too fragmented, not mounted' message.
  20.    To find out an appropriate value, run SCANDISK /FRAGMENT under DOS on the
  21.    CVF dmsdos refuses to mount. It is recommended to use a slightly larger
  22.    number here just in case you want to enlarge the CVF under DOS later. 
  23.    See documentation for details.
  24.    Note: For usualy msdos systems 10 should be sufficient; win95 seems to
  25.    need 20, with DriveSp 3 it may require 50 or higher. */
  26. #define MAXFRAGMENT 50
  27.  
  28. #define USE_VMALLOC
  29.  
  30. /* this is for safety: always wait until the fs access that came first
  31.    is finished before the next one is processed - undef this for speed
  32.    improvement - but it may cause problems in strange cases... */
  33. #undef SERIALIZE_RW_ACCESS
  34.  
  35. /* known compression methods */
  36. #define DS_0_0 0x00005344
  37. #define DS_0_1 0x01005344
  38. #define DS_0_2 0x02005344
  39. #define JM_0_0 0x00004D4A
  40. /* drivespace 3 high compression */ 
  41. #define JM_0_1 0x01004D4A
  42. /* drivespace 3 ultra compression */
  43. #define SQ_0_0 0x00005153
  44.  
  45. /* other defines for options */
  46. #define READ_ONLY -1
  47. #define UNCOMPRESSED -2
  48. #define GUESS -3
  49.  
  50. typedef struct
  51. { long sector_minus_1;
  52.   short size_lo_minus_1;
  53.   short size_hi_minus_1;
  54.   short unknown; /* some bits I don't know to handle.... */
  55.   short flags; /* 00...0uc - u=used, c=compressed */ 
  56. } Mdfat_entry;
  57.  
  58.  
  59. #define LISTSIZE 16384 /* must be a power of 2 */
  60.  
  61. /* flag values */
  62. #define D_EMPTY       0
  63. #define D_VALID       1    /* entry is valid -> cluster to be compressed */
  64. #define D_IN_D_ACTION 2    /* is being compressed by daemon */
  65. #define D_OVERWRITTEN 3    /* has been overwritten by dmsdos while daemon
  66.                             is compressing it -> throw away the result from
  67.                             the daemon */
  68.  
  69. typedef struct
  70. { int clusternr;
  71.   char cvfnr;
  72.   int length;   /* in bytes */
  73.   char flag;
  74.   int method;
  75. } Rwlist;
  76.  
  77. #ifdef __KERNEL__
  78.  
  79. #ifdef USE_VMALLOC
  80. #include<linux/mm.h>
  81. #define MALLOC(x) vmalloc(x)
  82. #define FREE(x) vfree(x)
  83. #else
  84. #include<linux/malloc.h>
  85. #define MALLOC(x) kmalloc(x,GFP_KERNEL)
  86. #define FREE(x) kfree(x)
  87. #endif
  88.  
  89. #ifdef SERIALIZE_RW_ACCESS
  90. #define LOCK_READWRITE lock_readwrite()
  91. #define UNLOCK_READWRITE unlock_readwrite()
  92. #else
  93. #define LOCK_READWRITE
  94. #define UNLOCK_READWRITE
  95. #endif
  96.  
  97. /* number of cvfs that can be handled at the same time */
  98. /* the following number *must* stay below 31 */
  99. #define MAXDBLFILES 10
  100.  
  101. /* cache sizes -- please note that the sum of these three are the number
  102.    of fs buffers dmsdos *permanently* uses - keep small on systems that
  103.    are short on memory */
  104. #define MDFATCACHESIZE 40
  105. #define DFATCACHESIZE 20
  106. #define BITFATCACHESIZE 10
  107.  
  108. /* defines which inode bits are 'misused' for the cvfnr*/
  109. /* adapted for new 2 GB support */
  110. #define DMSDOS_CVFNR_BITS 26
  111. #define DMSDOS_ORIGINO_MASK 0x3ffffff
  112. #define DMSDOS_MAX_DOS_SECTPERCLUST 64
  113.  
  114. /* defines for MDFAT entry */
  115. /* adapted for new 2 GB support (grrr... supposed and guessed, may be wrong) */
  116. /* was 0x1fffff before, reverse it if the new value causes problems */
  117. #define DBLSECTOR_MASK 0x3fffff
  118.  
  119. extern int dmsdos_lookup(struct inode *dir,const char *name,int len,
  120.     struct inode **result);
  121. extern int dmsdos_create(struct inode *dir,const char *name,int len,int mode,
  122.     struct inode **result);
  123. extern int dmsdos_mkdir(struct inode *dir,const char *name,int len,int mode);
  124. extern int dmsdos_rmdir(struct inode *dir,const char *name,int len);
  125. extern int dmsdos_unlink(struct inode *dir,const char *name,int len);
  126. extern int dmsdos_rename(struct inode *old_dir,const char *old_name,int old_len,
  127.     struct inode *new_dir,const char *new_name,int new_len
  128. #ifdef __FOR_KERNEL_2_0_1
  129.     , int must_be_dir
  130. #endif
  131.     );
  132. extern void dmsdos_put_inode(struct inode *inode);
  133. extern void dmsdos_put_super(struct super_block *sb);
  134. extern struct super_block *dmsdos_read_super(struct super_block *s,
  135.                         void *data,int);
  136. #ifdef __FOR_KERNEL_1_3
  137. extern void dmsdos_statfs(struct super_block *sb,struct statfs *buf,int);
  138. #else
  139. extern void dmsdos_statfs(struct super_block *sb,struct statfs *buf);
  140. #endif
  141. extern int dmsdos_bmap(struct inode *inode,int block);
  142. extern void dmsdos_read_inode(struct inode *inode);
  143. extern void dmsdos_write_inode(struct inode *inode);
  144. extern int dmsdos_notify_change(struct inode *,struct iattr *);
  145. extern struct inode_operations dmsdos_dir_inode_operations;
  146. extern int dmsdos_readdir (struct inode *inode, struct file *filp,
  147. #ifdef __FOR_KERNEL_1_3
  148.         void *dirent, filldir_t);
  149. #else
  150.     struct dirent *dirent, int count);
  151. #endif
  152. extern struct inode_operations dmsdos_file_inode_operations;
  153. extern struct inode_operations dmsdos_file_inode_operations_1024;
  154. extern int dmsdos_file_read(struct inode *, struct file *, char *, int);
  155. extern int dmsdos_file_write(struct inode *, struct file *,
  156. #ifdef __FOR_KERNEL_1_3
  157.                              const
  158. #endif
  159.                              char *, int);
  160. extern struct inode_operations dmsdos_file_inode_operations_no_bmap;
  161. extern void dmsdos_truncate(struct inode *inode);
  162. extern int dmsdos_mmap(struct inode *, struct file *, struct vm_area_struct *);
  163.  
  164. #endif
  165.  
  166. /* this must be known outside the kernel too */
  167. typedef struct {
  168.   int s_dcluster;/*[45-46]*/
  169.   int s_mdfatstart;/*[36-37]+1*/
  170.   int s_fatstart;/*[39-40]+[14-15]*/ 
  171.   int s_rootdir;/*[41-42]+[39-40]*/
  172.   int s_rootdiranzentry;
  173.   int s_sectperclust;
  174.   int s_first[MAXFRAGMENT];
  175.   int s_anzahl[MAXFRAGMENT];
  176.   int s_16bitfat;
  177.   int s_datastart;
  178.   int s_dataend;
  179.   int s_comp;
  180.   int s_bootblock;/*[39-40]*/
  181.   int s_cfaktor;
  182.   int s_full;
  183.   int s_max_cluster;
  184.   int s_max_cluster2;
  185.   int s_support_lfn;
  186. } Dblsb;
  187.  
  188. #ifdef __KERNEL__
  189.  
  190. typedef struct {
  191.   struct buffer_head * a_buffer;
  192.   unsigned int a_area;
  193.   unsigned long a_time;
  194.   unsigned int a_cvfnr;
  195.   unsigned int a_acc;
  196. } Acache;
  197.  
  198. struct buffer_head* read_dbl_sector(struct super_block*,
  199.                                     int dblsector,int cvfnr);
  200. struct buffer_head* noread_dbl_sector(struct super_block*,
  201.                                     int dblsector,int cvfnr);
  202. void bh_free(struct super_block*, struct buffer_head*);
  203. void bh_dirty(struct super_block*, struct buffer_head*);
  204. void dbl_mdfat_value(struct super_block*,int clusternr,int cvfnr,
  205.                      Mdfat_entry*new,Mdfat_entry*mde);
  206. int dbl_fat_nextcluster(struct super_block*,int clusternr,int cvfnr,int*);
  207. int dbl_bitfat_value(struct super_block*,int sektornr,int cvfnr,int*);
  208. int dbltest(struct inode* inode);
  209. int dostest(struct inode* inode);
  210. int dbl_init(struct super_block* sb, void* datai, int,int,int,int,int,int);
  211. int dmsdos_readdirx(struct inode *inode,struct file *filp,
  212. #ifdef __FOR_KERNEL_1_3
  213.         void *dirent,filldir_t filldir);
  214. #else
  215.     struct dirent *dirent,int count);
  216. #endif
  217. int dmsdos_file_readx(
  218.     struct inode *inode,
  219.     struct file *filp,
  220.     char *buf,
  221.     int count);
  222. void dmsdos_read_inodex(struct inode *inode);
  223. int dmsdos_lookupx(struct inode *dir,const char *name,int len,
  224.     struct inode **result);
  225. int dmsdos_read_cluster(struct super_block*,
  226.                         unsigned char*clusterd, int clusternr,int cvfnr);
  227. void exit_dbl(struct super_block*sb);
  228. void free_chain(struct super_block*sb, int clusternr, int cvfnr);
  229. int find_free_bitfat(struct super_block*sb, int sektornr,int cvfnr, int size);
  230. int allocate_cluster(struct super_block*sb, int cvfnr);
  231. int allocate_first_cluster(struct super_block*sb, int cvfnr);
  232. int allocate_next_cluster(struct super_block*sb, int akt_cluster, int cvfnr);
  233. int replace_existing_cluster(struct super_block*sb, int cluster, 
  234.                              int near_sector,
  235.                              Mdfat_entry*, int cvfnr);
  236. int allocate_first_dir_cluster(struct super_block*sb,int cvfnr);
  237. int allocate_next_dir_cluster(struct super_block*sb, int akt_cluster,
  238.                               int cvfnr);
  239. int scan_dbl_dir_4_empty(struct super_block*sb, int dirstartclust, int cvfnr);
  240. int scan_dbl_dir_4_n_empty(struct super_block*sb, int dirstartclust, int cvfnr,
  241.                            int n, int*lfn_inos);
  242. #endif /*__KERNEL__*/
  243. int compress(unsigned char* clusterk, unsigned char* clusterd, 
  244.                       int size, int method,int);
  245. #ifdef __KERNEL__
  246. int dmsdos_write_cluster(struct super_block*sb,
  247.                          unsigned char* clusterd, int length, int clusternr,
  248.                          int near_sector, int cvfnr, int ucflag);
  249. int dmsdos_file_writex(struct inode *inode, struct file *filp, 
  250. #ifdef __FOR_KERNEL_1_3
  251.                        const
  252. #endif
  253.                        char *buf, int count);
  254. void dmsdos_truncatex(struct inode *inode);
  255. void dmsdos_put_inodex(struct inode *inode);
  256. void dmsdos_write_inodex(struct inode *inode);
  257. int dmsdos_notify_changex(struct inode * inode,struct iattr * attr);
  258. int dmsdos_createx(struct inode *dir,const char *name,int len,int mode,
  259.     struct inode **result);
  260. int dmsdos_mkdirx(struct inode *dir,const char *name,int len,int mode);
  261. int dmsdos_rmdirx(struct inode *dir,const char *name,int len);
  262. int dmsdos_unlinkx(struct inode *dir,const char *name,int len);
  263. int dmsdos_unlink_umsdos(struct inode *dir,const char *name,int len);
  264. int dmsdos_renamex(struct inode *old_dir,const char *old_name,int old_len,
  265.     struct inode *new_dir,const char *new_name,int new_len
  266. #ifdef __FOR_KERNEL_2_0_1
  267.     , int must_be_dir
  268. #endif
  269.     );
  270. #define CHS(i) ( (unsigned short)i[0]|(unsigned short)i[1]<<8 )
  271.  
  272. #endif /*__KERNEL__*/
  273.  
  274. #define CHL(i) ( (unsigned long)i[0]|(unsigned long)i[1]<<8| \
  275.                  (unsigned long)i[2]<<16|(unsigned long)i[3]<<24 )
  276.  
  277. #ifdef __KERNEL__
  278.  
  279. struct buffer_head* read_real_sector(struct super_block* sb,int sector);
  280. struct buffer_head* noread_real_sector(struct super_block* sb,int sector);
  281. int dbl_mdfat_cluster2sector(struct super_block*sb,int clusternr,int cvfnr);
  282. int read_dbl_direntry(struct super_block*sb,
  283.                       int dbl_clusterno,int cvfnr,int entrynr,
  284.                       unsigned char*buf);
  285. int dmsdos_get_entry(struct inode *dir, loff_t *pos,unsigned char * buf);
  286. int dmsdos_parent_ino(struct inode*dir);
  287. int scan_dbl_dir_4_filename(struct super_block*sb, int dirstartclust,
  288.                             unsigned const char*tofind,int len,
  289.                             int cvfnr);
  290. int dmsdos_ioctl_dir(struct inode*dir, struct file*filp, unsigned int cmd,
  291.                      unsigned long data);
  292. int read_lfn_direntry(struct super_block*sb,int dirstartclust,int cvfnr,
  293.                        int entrynr, char*longname, unsigned char*buf,
  294.                        int*lfn_inos);
  295. int scan_dbl_dir_4_lfn(struct super_block*sb, int dirstartclust,
  296.                        const char*tofind,int len,int cvfnr,int*lfn_inos);
  297. int dmsdos_get_lfn_entry(struct inode *dir, loff_t *pos,unsigned char * buf,
  298.                          char*longname);
  299. int remove_lfn_entry(struct super_block*sb, int dirstartclust,
  300.                      const char*tofind, int len, int cvfnr);
  301. int create_lfn_entry(struct super_block*sb, int dirstartclust,
  302.                      const char*longname, int len, int cvfnr);
  303. int fixdir(struct super_block * sb, int cvfnr);
  304. int simple_check(struct super_block*sb, int cvfnr);
  305. int init_dmsdos_fs(void);
  306. int try_daemon(int clusternr, int cvfnr, int length, int method);
  307. void clear_list_cvfnr(int cvfnr);
  308. void clear_list(void);
  309. int moveback(struct super_block*sb, int clusternr, int cvfnr);
  310. void lock_readwrite(void);
  311. void unlock_readwrite(void);
  312.  
  313. #endif /* __KERNEL__ */
  314.  
  315. /* defines for external dmsdos utilities */
  316. /* ioctl_dir commands, write is only allowed by root, read_block too */
  317.  
  318. #define DMSDOS_IOCTL_MIN 0x2000
  319. #define DMSDOS_IOCTL_MAX 0x201F
  320. #define DMSDOS_GET_DBLSB 0x2000
  321. #define DMSDOS_EXTRA_STATFS 0x2001
  322. #define DMSDOS_READ_BLOCK 0x2002
  323. #define DMSDOS_WRITE_BLOCK 0x2003
  324. #define DMSDOS_READ_DIRENTRY 0x2004
  325. #define DMSDOS_WRITE_DIRENTRY 0x2005
  326. #define DMSDOS_READ_BITFAT 0x2006
  327. #define DMSDOS_WRITE_BITFAT 0x2007
  328. #define DMSDOS_READ_MDFAT 0x2008
  329. #define DMSDOS_WRITE_MDFAT 0x2009
  330. #define DMSDOS_READ_DFAT 0x200a
  331. #define DMSDOS_WRITE_DFAT 0x200b
  332. #define DMSDOS_SET_COMP 0x200c
  333. #define DMSDOS_SET_CF 0x200d
  334. #define DMSDOS_SIMPLE_CHECK 0x200e
  335. #define DMSDOS_DUMPCACHE 0x200f
  336. #define DMSDOS_D_ASK 0x2010
  337. #define DMSDOS_D_READ 0x2011
  338. #define DMSDOS_D_WRITE 0x2012
  339. #define DMSDOS_D_EXIT 0x2013
  340. #define DMSDOS_MOVEBACK 0x2014
  341. #define DMSDOS_SET_MAXCLUSTER 0x2015
  342.  
  343. #define IS_DMSDOS_IOCTL(cmd) ((cmd)>=DMSDOS_IOCTL_MIN&&(cmd)<=DMSDOS_IOCTL_MAX)
  344.  
  345. #endif
  346.